package com.cjm.connect;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class test9 {
    public void main(String[] args) {
        testDML();
    }
    public void testDML(){
//        连接数据库
        Connection connection = null;
//        sql语句
        String sql = "update admin set name = ? where password = ?";
//        创建PreparedStatement
        PreparedStatement preparedStatement = null;
        try {
            connection = test8.getConnection();
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,"曹家蒙");
            preparedStatement.setString(2,"cjm");
            preparedStatement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            test8.close(connection,null,preparedStatement);
        }


    }
}
